package com.aios.action;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import com.aios.model.AmountPowerModel;

public class GetAmountPowerAction extends AbstractAction {

	private static final long serialVersionUID = 1L;

	private Integer tap_group_id;
	private Integer report_type;
	private String date_start;
	private String date_end;
	
	private AmountPowerModel response;
	
	public static SimpleDateFormat DateFormat = new SimpleDateFormat("yyyy-MM-dd");
	
	public String returnAmountPower() {
		return SUCCESS;
	}

	public AmountPowerModel getResponse() throws ParseException {
		if(this.report_type == null || this.report_type >= 5) {
			this.report_type = 0;
		}
		
		Calendar startDate = Calendar.getInstance();
		startDate.setTime(DateFormat.parse(date_start));
		

		Calendar endDate = Calendar.getInstance();
		endDate.setTime(DateFormat.parse(date_end));
		
		response = new AmountPowerModel(this.tap_group_id, this.report_type, startDate, endDate);
		return response;
	}

	public void setResponse(AmountPowerModel response) {
		this.response = response;
	}

	public void setTap_group_id(int tap_group_id) {
		this.tap_group_id = tap_group_id;
	}

	public void setReport_type(Integer report_type) {
		this.report_type = report_type;
	}

	public void setDate_start(String date_start) {
		this.date_start = date_start;
	}

	public void setDate_end(String date_end) {
		this.date_end = date_end;
	}

	@Override
	public String toString() {
		return "GetAmountPowerAction [tab_group_id=" + tap_group_id
				+ ", report_type=" + report_type + ", date_start=" + date_start
				+ ", date_end=" + date_end + "]";
	}
	
	
	
}
